<template>
  <div>
    <div style="marginTop: 5px; marginBottom: 5px">
      <span>1. 请点击 &nbsp;“<span style="color : red">模板</span>” &nbsp;按钮，下载模板。</span>
      <el-button size="mini" type="primary" icon="el-icon-download" plain @click="downloadTemplate">模 板</el-button>
    </div>
    <div style="marginBottom: 5px">
      <p>2. 点击“<span style="color : red">选择</span>”按钮，选择要导入的xls文件，内容为：VIN、保险到期年、保险到期月、保险到期日、保险备注1、保险备注。</p>
    </div>
    <el-upload
      ref="upload"
      class="importPrice"
      action="/api/dmscloud.repair/customerFeign/Remind/InsuranceImport"
      accept=".xlsx,.xls"
      :limit="1"
      :headers="headersObj"
      :on-success="showErrorList"
      :on-exceed="handleExceed"
    >
      <el-button size="small" type="primary" plain>点击上传</el-button>
    </el-upload>

    <div>
      <p style="marginTop: 5px;marginBottom: 5px">3.文件选择后，点击“<span style="color : red">载入</span>”按钮，完成载入操作。</p>
      <el-button size="mini" type="primary" icon="el-icon-upload2" plain>载 入</el-button>
      <el-button size="mini" type="primary" plain>返 回</el-button>
    </div>
    <!-- <UploadFile
    action-url="/api/dmscloud.sysbasedata/vehicleProduct/car/importCarPrice"
    :initial-value="form.fileList"

    @change="successHandler"
    >点击上传
    </UploadFile> -->
  </div>
</template>
<script>
// export default {
//   name: 'aaa',
//   data() {
//     return {
//       form: {
//         fileList: [],
//       }
//     };
//   },
//   methods: {
//     successHandler(val) {
//       this.form.fileList = val;
//     }
//   }
// };
import { getToken, getAppId } from '@/assets/js/auth';
export default {
  data() {
    return {
      headersObj: {
        jwt: getToken(),
        appId: getAppId(),
        userAgent: 'pc'
      },
      errorList: []
    };
  },
  methods: {
    downloadTemplate() {
      window.open('/static/tinymce/template/insuranceDueRemindTemplate.xls');
    },
    showErrorList(response, file, fileList) {
      this.errorList = response.data;
      if (this.errorList == [] || this.errorList == null) {
        this.$message('上传成功! 0条处理失败');
      } else {
        this.$message('上传成功!  ' + this.errorList.length + '条处理失败');
      }
    },
    handleExceed(files, fileList) {
      this.$message(`只能选择一个文件`);
    }
  }
};
</script>
<style lang="less" scoped></style>>
